import {defineConfig} from 'vite'
import vue from '@vitejs/plugin-vue'
import postCssPxToRem from 'postcss-pxtorem';
import path from 'path';
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'


export default defineConfig({
    plugins: [
        vue(),
        AutoImport({
            resolvers: [ElementPlusResolver()],
        }),
        Components({
            resolvers: [ElementPlusResolver()],
        })
    ],
    css: {
        preprocessorOptions: {
            scss: {
                additionalData: '@import "@/assets/style/var.scss";',
            },
        },
        postcss: {
            plugins: [
                postCssPxToRem({
                    rootValue: 192, // 1rem的大小
                    propList: ['*'], // 需要转换的属性，这里选择全部都进行转换
                }),
            ],
        },
    },
    base: './',	//不加打包后白屏
    server: {
        host: '0.0.0.0',
        // port: 8080,
        open: true
    },
    resolve: {
        alias: {
            '@': path.resolve(__dirname, 'src'),
            '/components': path.resolve(__dirname, 'src/components'),
        },
    },
})
